﻿#Region "Copyright/License"

'  Copyright (C) 2011, 2012, 2013 Paycircuit.com, Thinking Spot, Ed Chavez
'  http://goo.gl/jty8r
' 
'  Licensed under the Apache License, Version 2.0 (the "License");
'  you may not use this file except in compliance with the License.
'  You may obtain a copy of the License at
' 
'       http://www.apache.org/licenses/LICENSE-2.0
' 
'  Unless required by applicable law or agreed to in writing, software
'  distributed under the License is distributed on an "AS IS" BASIS,
'  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
'  See the License for the specific language governing permissions and
'  limitations under the License.

#End Region

Imports System.Runtime.Serialization

Namespace google.iap

    <DataContract()>
    Public Class JWTHeaderObject
        Inherits JWTHeader

        ''' <summary>
        ''' When using this constructor, refer to property Intellisense documentation/information/hints for requirements.
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub New()
        End Sub

        ''' <summary>
        ''' Alg only constructor.
        ''' </summary>
        ''' <param name="alg">Google In-App Payments only supports "HS256".</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal alg As String)
            MyBase.alg = JWTHelpers.parseJWTHashEnum(alg).ToString
        End Sub

        ''' <summary>
        ''' Alg only constructor.
        ''' </summary>
        ''' <param name="alg">Google In-App Payments only supports JWTHash.HS256 (HS256)</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal alg As JWTHash)
            MyBase.alg = alg.ToString
        End Sub

        ''' <summary>
        ''' Alg and Kid constructor.
        ''' </summary>
        ''' <param name="alg">Google In-App Payments only supports "HS256"</param>
        ''' <param name="kid">At this time your Google account only has one key so if you will use this consturctor: "1"</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal alg As String, ByVal kid As String)
            MyBase.alg = JWTHelpers.parseJWTHashEnum(alg).ToString
            MyBase.kid = kid
        End Sub

        ''' <summary>
        ''' Alg and Kid constructor.
        ''' </summary>
        ''' <param name="alg">Google In-App Payments only supports JWTHash.HS256 (HS256)</param>
        ''' <param name="kid">At this time your Google account only has one key so if you will use this consturctor: "1"</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal alg As JWTHash, ByVal kid As String)
            MyBase.alg = alg.ToString
            MyBase.kid = kid
        End Sub

        ''' <summary>
        ''' Alg, Kid and Typ constructor.
        ''' </summary>
        ''' <param name="alg">Google In-App Payments only supports "HS256"</param>
        ''' <param name="kid">At this time your Google account only has one key so if you will use this consturctor: "1"</param>
        ''' <param name="typ">Set to "JWT"</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal alg As String, ByVal kid As String, ByVal typ As String)
            MyBase.alg = JWTHelpers.parseJWTHashEnum(alg).ToString
            MyBase.kid = kid
            MyBase.typ = typ
        End Sub

        ''' <summary>
        ''' Alg, Kid and Typ constructor.
        ''' </summary>
        ''' <param name="alg">Google In-App Payments only supports JWTHash.HS256 (HS256)</param>
        ''' <param name="kid">At this time your Google account only has one key so if you will use this consturctor: "1"</param>
        ''' <param name="typ">Set to "JWT"</param>
        ''' <remarks></remarks>
        Public Sub New(ByVal alg As JWTHash, ByVal kid As String, ByVal typ As String)
            MyBase.alg = alg.ToString
            MyBase.kid = kid
            MyBase.typ = typ
        End Sub

        ''' <summary>
        ''' 06/21/2011: In-App Payments API currently uses JWT v1 and HMAC SHA-256 encryption
        ''' </summary>
        ''' <remarks>http://sites.google.com/site/inapppaymentsapi/reference#jwt</remarks>
        Enum JWTHash
            'HMAC using SHA
            HS256
            HS384
            HS512

            'not supported for Google In-App Payments
            none

            'RSA using SHA: none of these are currently used in this library (futures)
            'RS256
            'RS384
            'RS512

            'ECDSA using P-256 curve and SHA: none of these are currently used in this library (futures)
            'ES256
            'ES384
            'ES512
        End Enum

    End Class

End Namespace